﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Comdiv.QWeb.Events;
using NUnit.Framework;

namespace Comdiv.QWeb.Test.SystemActions
{
	[TestFixture]
	public class reset_action
	{
		[Test]
		public void  reset_invoked() {
			bool invoked = false;
			var reg = new QWebServiceRegistry();
			reg.Events.Add(new QWebEventHandler<ResetEvent>(e=>
			                                                	{
			                                                		if(e.Data.IsSet("test.1")) {
			                                                			invoked = true;
			                                                		}
			                                                	}));
			new QWebHandler(reg).ProcessRequest(new QWebContext("http://localhost/qweb/reset.qweb").Set("rp.test.1", true));
			Assert.True(invoked);

		}

		[Test]
		public void all_supportd()
		{
			bool invoked = false;
			var reg = new QWebServiceRegistry();
			reg.Events.Add(new QWebEventHandler<ResetEvent>(e =>
			{
				if (e.Data.IsSet("test.1"))
				{
					invoked = true;
				}
			}));
			new QWebHandler(reg).ProcessRequest(new QWebContext("http://localhost/qweb/reset.qweb").Set("all", true));
			Assert.True(invoked);

		}

		[Test]
		public void no_not_seleced()
		{
			bool invoked = false;
			var reg = new QWebServiceRegistry();
			reg.Events.Add(new QWebEventHandler<ResetEvent>(e =>
			{
				if (e.Data.IsSet("test.1"))
				{
					invoked = true;
				}
			}));
			new QWebHandler(reg).ProcessRequest(new QWebContext("http://localhost/qweb/reset.qweb").Set("rp.test.2", true));
			Assert.False(invoked);

		}
	}

	
}
